package collection;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 集合仅能保存引用类型元素，并且保存的是元素的地址
 */
public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
//        c.add(123);//c.add(Integer.value(123));

        Point p = new Point(1,2);
        c.add(p);//将p变量的值(地址)存入集合c中
        System.out.println("p:"+p);
        System.out.println("c:"+c);

        p.setX(2);
        System.out.println("p:"+p);
        System.out.println("c:"+c);

    }
}
